//
//  YFPayManager.h
//  project
//
//  Created by Winny Zhang on 2019/3/29.
//  Copyright © 2019 健健. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "YFWechatPayOrder.h"

/**
 微信支付支付完成回调

 @param isSuccess 是否支付成功
 @param message 支付未成功的提示信息
 */
typedef void (^YFWechatPayCompletion)(BOOL isSuccess, NSString * _Nonnull message);

/**
 支付宝支付完成回调

 @param result 支付结果
 */
typedef void (^YFAliPayCompletion)(NSDictionary * _Nullable result);


/**
 银联支付完成回调

 @param result 支付结果
 @param code 错误码
 */
typedef void (^YFUnionPayCompletion)(NSString * _Nonnull code, NSDictionary * _Nullable result);



typedef NS_ENUM(NSInteger, YFPayPlatform) {
    YFPayPlatformAliPay = 0,
    YFPayPlatformWechat,
    YFPayPlatformUnionPay
};

NS_ASSUME_NONNULL_BEGIN

@interface YFPayManager : NSObject
/**
 绝对单例
 
 @return 单例
 */
+ (instancetype)shared;

/**
 注册微信、银联
 支付宝不用注册
 */
+ (void)registerPlatforms;

/**
 微信支付设置回调
 
 @param url 要处理的 url
 */
+ (void)wechatHandleOpenWith:(NSURL *)url;

/**
 Alipay支付设置回调
 
 @param url 要处理的 url
 @param callback 回调处理
 */
+ (void)aliPayprocessOrderWith:(NSURL *)url callback:(YFAliPayCompletion)callback;

/**
 银联支付设置回调
 
 @param url 要处理的 url
 @param callback 回调处理
 */
+ (void)unionPayHandleOpenWith:(NSURL *)url callBack:(YFUnionPayCompletion)callback;

/**
 微信支付
 
 @param order 订单
 @param completion 完成回调
 */
+ (void)wechatPay:(YFWechatPayOrder *)order completion:(YFWechatPayCompletion)completion;

/**
 微信支付
 
 @param order 订单
 @param completion 完成回调
 */
- (void) wechatPay:(YFWechatPayOrder *)order completion:(YFWechatPayCompletion)completion;

/**
 支付宝支付
 
 @param order 支付订单
 @param completion 支付结果回调
 */
+ (void)aliPay:(NSString *)order completion:(YFAliPayCompletion)completion;

/**
 支付宝支付
 
 @param order 支付订单
 @param completion 支付结果回调
 */
- (void)aliPay:(NSString *)order completion:(YFAliPayCompletion)completion;

/**
 银联支付
 
 @param order 交易流水号
 @param viewController 需要展示的 ViewController 用户内嵌收银台的展示
 @param completion 支付结果回调
 */
+ (void)unionPay:(NSString *)order viewController:(UIViewController *)viewController completion:(YFUnionPayCompletion)completion;

/**
 银联支付
 
 @param order 交易流水号
 @param viewController 需要展示的 ViewController 用户内嵌收银台的展示
 @param completion 支付结果回调
 */
- (void)unionPay:(NSString *)order viewController:(UIViewController *)viewController completion:(YFUnionPayCompletion)completion;

@end

NS_ASSUME_NONNULL_END
